﻿{template 'common/header'}
{template '_header'}
<title>{if empty($cate)}积分商城{else}{$cate['name']}{/if}</title>
<link href="http://libs.baidu.com/bootstrap/3.0.3/css/bootstrap.min.css" rel="stylesheet">
<script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
<script src="http://libs.baidu.com/bootstrap/3.0.3/js/bootstrap.min.js"></script>
<style type='text/css'>
  body { background:#fff;font-family:Noto Sans S Chinese;}
#list_loading { padding:10px 0 10px 0;color:#666;text-align: center;width:100%;float:left;}
.header{height:auto;width:100%;padding:0px;text-align:center;}
.header .user{height:180px;padding:10px;}
.header .user .user-head{height:100px;width:100px;background:#fff;border-radius:100%;border:2px solid #fff;margin:auto;}
.header .user .user-head img{height:100px;width:100px;border-radius:100%;}
.index-jifen{height:50px;background:#fff;color:#f90;text-align:center;}
.index-jifen a{color:#999;font-size:14px;}
.list .good{width:90%;height:450px;background-color:#EFEFEF;margin-top: 5px;margin-left: 5%;}
.index_sub{height:80px;background-color:#EFEFEF;}
.list{margin-top:20px;}
.fa-database:before{content:"";}
.index_sub{line-height: 0px;}
#myModal{top:25%;}
</style>
<div id='container'></div>
<script id='tpl_main' type='text/html'>
    <div class="header">
        <div class="user">
            <div class="user-head"><img src="<%member.avatar%>"/></div>
            <div class="user-info">
                <div class="user-name" style="margin-top:10px;letter-spacing: 3px;"><b><%member.nickname%></b></div>
                <div class="user-time" style="margin-top:10px;font-size:10px;color:#999;"><span style="letter-spacing: 3px;">关注时间:</span> {php echo date('Y-m-d H:i',$member['createtime']);}</div>
            </div>
        </div>
   </div>
    <div class="index-jifen">
    <a href="{php echo $this->createPluginMobileUrl('creditshop/creditlog')}">我的积分<br /><b style="font-size:30px;color:#000;"><%credit%></b> </a>
    </div>
    <div style="height:25px;width:100%;">
        <!--<div style="font-size: 12px;height:20px;width:80px;float:right;color:#000;border:1px solid #000;margin-right:10px;text-align: center;line-height: 20px;" data-toggle="modal" data-target="#myModal">积分规则？</div>-->
        <a style="font-size: 12px;height:20px;width:80px;float:right;color:#000;border:1px solid #000;margin-right:10px;text-align: center;line-height: 20px;" data-toggle="modal" href="#myModal">积分规则？</a>
    </div>
    <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
   <div class="modal-dialog">
     <div class="modal-content">
         <div class="modal-header">
            <button type="button" class="close" 
                data-dismiss="modal" aria-hidden="true">
                   &times;
             </button>
              <h4 class="modal-title" id="myModalLabel">积分规则：</h4>
         </div>
         <div class="modal-body">
            <p>1.小妖家公众号签到赚取，进入小妖家平台，点击“每日签到”，可每日获取积分奖励，每次签到奖励5积分，连续签到5天额外赠送10积分，累计签到10次奖励20积分，累计签到排名第一10次奖励20积分。</p>
            <p>2.购物送积分，购买小妖家商城任意商品都会获得数额不等的积分。</p>
            <p>3.转发送积分，阅读转发小妖家推送文章即可得10积分。</p>
            <p>4.小妖家会定期发布最新产品在积分兑换商城中，供买家免费兑换试用。</p>
         </div>
     </div>
    </div>
   </div>
    <div class="index_sub" style="font-weight:900;">
        <div style="width:49%;float:left;height:60px;margin-top: 10px;">
        <img src="http://wx.lanxuevip.com/web/resource/images/money.png" style="width:30px;"><br/>
        <a href="{php echo $this->createPluginMobileUrl('creditshop/lists')}"> 积分兑换</a>
        </div>
        <div style="float:left;background-color:#262637;width:2px;height:60px;margin-top: 10px;"></div>
        <div style="width:49%;float:left;height:60px;margin-top: 10px;">
        <img src="http://wx.lanxuevip.com/web/resource/images/liwu.png" style="width:30px;"><br/>
        <a href="{php echo $this->createPluginMobileUrl('creditshop/log')}"> 兑换记录</a>
        </div>
    </div>
<div class="list">
<div id="container_list"></div>
</div>
 <div class="list_footer" style="margin-top:10px;">活动由{$shop['name']}提供，与商品生产商无关。</div>
</script>
<script id='tpl_empty' type='text/html'>
    <div class="record_ico"><i class="fa fa-cubes"></i></div>
    <div class="record_no">未找到任何产品~</div>
</script>

<script id='tpl_list' type='text/html'>
    <%each list as goods%>
        <div class="good" onclick="location.href='{php echo $this->createPluginMobileUrl('creditshop/detail')}&id=<%goods.id%>'">
             <div class="info">
                 
                <div class="classs" style="margin-top: 10px;"><%goods.subtitle%><%if goods.type=='1'%><span class="span1">抽奖</span><%else%><span class="span2" style="background-color:#323232;padding:7px 8px;" >小妖家</span><%/if%></div>
                <div class="img" style="height:320px;margin-top: 20px;"><img src="<%goods.thumb%>" style="max-height:300px;"/></div>
                <div class="name"><b><%goods.title%></b></div>
                <div class="price" style="float:right;">
                      <%if goods.acttype==0%>
                            <%goods.credit%><i class="fa fa-database"></i> <i class="fa fa-plus"></i> <%goods.money%><i class="fa fa-rmb"></i>
                       <%/if%>
                       <%if goods.acttype==1%>
                          <%goods.credit%>积分<i class="fa fa-database"></i>
                       <%/if%>
                       <%if goods.acttype==2%>
                          <%goods.money%><i class="fa fa-rmb"></i>
                       <%/if%>
                </div>
            </div>
     </div>
    <%/each%>
</script>
<script language='javascript'>
    var page= 1;
 
    require(['tpl', 'core'], function(tpl, core) {
       
        core.pjson('creditshop/lists',{cate:"{$cateid}"},function(json){
                     
                  $('#container').html(  tpl('tpl_main',json.result) );
                     
                     if(json.result.total<=0){
                        $('#container_list').html(  tpl('tpl_empty') );
                        $('.list_footer').hide();
                     }else{
                           $('#container_list').html(  tpl('tpl_list',json.result) );
                     }
                     if (json.result.list.length < json.result.pagesize) {
                            return;
                     }
                     var loaded = false;
                      var stop=true; 
                      $(window).scroll(function(){ 
                          if(loaded){ 
                              return;
                          }
                            totalheight = parseFloat($(window).height()) + parseFloat($(window).scrollTop()); 
                            if($(document).height() <= totalheight){ 
                                
                                if(stop==true){ 
                                    stop=false; 
                                    $("#container_list").append('<div id="list_loading"><i class="fa fa-spinner fa-spin"></i> 正在加载...</div>');
                                    page++;
                                    core.pjson('creditshop/log', {page:page,cate:"{$cateid}"}, function(morejson) {  
                                        stop = true;
                                        $('#list_loading').remove();
                                        $("#container_list").append(tpl('tpl_list', morejson.result));
                                        if (morejson.result.list.length <morejson.result.pagesize) {
                                 
                                            $('#container_list').append('<div id="list_loading">已经加载完全部记录</div>');
                                            loaded = true;
                                            $(window).scroll = null;
                                            return;
                                        }
                                    },true); 
                                } 
                            } 
                        });
            
                  
              
                     
         },true);
   });
</script>
{template 'common/footer'}

{template 'common/footer'}